package com.ccom.test.rabbitmq;

import com.ccom.core.common.model.BaseMap;
import com.ccom.starter.rabbitmq.annotation.RabbitComponent;
import com.ccom.starter.rabbitmq.core.BaseRabbiMqHandler;
import com.ccom.starter.rabbitmq.listenter.MqListener;
import com.ccom.test.constant.TestConstant;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;

/**
 * @Description:
 * @author: jjzhang24
 * @date: 2021年12月20日
 */
@Slf4j
@RabbitListener(queues = TestConstant.MQ_CCOM_PLACE_ORDER_TIME)
@RabbitComponent(value = "placeOrderTimeQueue")
public class PlaceOrderTimeQueue extends BaseRabbiMqHandler<BaseMap> {

    @RabbitHandler
    public void onMessage(BaseMap baseMap, Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) long deliveryTag) {
        super.onMessage(baseMap, deliveryTag, channel, new MqListener<BaseMap>() {
            @Override
            public void handler(BaseMap map, Channel channel) {
                String message = map.get("orderId").toString();
                log.info("MQ PlaceOrderTimeQueue ccom_place_order_time get message,orderId:{} ", message);
            }
        });
    }
}
